package com.tianqi.code.lottery.domain.strategy.service.algorithm;

import com.tianqi.code.lottery.domain.strategy.model.vo.AwardRateVo;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 */
public abstract class AbstractDrawAlgorithm implements IDrawAlgorithm {

    // 奖品区间概率值，strategyId -> [awardId->begin、awardId->end]
    protected Map<Long, List<AwardRateVo>> awardRateInfoMap = new ConcurrentHashMap<>();


    @Override
    public void initRateTuple(Long strategyId, List<AwardRateVo> awardRateVoInfoList) {

        awardRateInfoMap.put(strategyId, awardRateVoInfoList);
        doInit(strategyId, awardRateVoInfoList);
    }

    @Override
    public boolean isExistRateTuple(Long strategyId) {
        return awardRateInfoMap.containsKey(strategyId);
    }

    abstract protected void doInit(Long strategyId, List<AwardRateVo> awardRateVoInfoList);
}
